<!DOCTYPE html>
<html>
<head>
    <title>MVVC Framework Example</title>
</head>
<body>
    <div id="data-display"></div>
    <button onclick="updateData()">Update Data</button>

    <script>
        // 模型（Model）
        class Model {
            constructor(data) {
                this.data = data;
            }

            getData() {
                return this.data;
            }

            setData(newData) {
                this.data = newData;
            }
        }

        // 视图模型（View Model）
        class ViewModel {
            constructor(model) {
                this.model = model;
                this.displayData = ko.observable(this.model.getData());
            }

            updateData() {
                const newData = "更新后的数据";
                this.model.setData(newData);
                this.displayData(newData);
            }
        }

        // 初始化
        const model = new Model("初始数据");
        const viewModel = new ViewModel(model);
        ko.applyBindings(viewModel, document.getElementById("data-display"));

        // 更新数据并显示
        function updateData() {
            viewModel.updateData();
        }
    </script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>
</body>
</html>